import Vue from 'vue';
import Vuex from 'vuex';
import print from './print.js';
Vue.use(Vuex),
    Vue.use(Vuex);


// 用来存储数据
const state = {
        guan: [],
        list: [],
    }
    // 响应组件中的事件
const actions = {

    }
    // 操作数据
const mutations = {
        ADDGUAN(state, list) {
            if (state.guan.length == 0) {
                Vue.set(list, 'number', 1)
                state.guan.push(list)
                return;
            }
            for (let index = 0; index < state.guan.length; index++) {
                if (state.guan[index].cook_id == list.cook_id) {
                    state.guan[index].number++;
                    return;
                }
            }
            Vue.set(list, 'number', 1)
            state.cart.push(list)
        },
    }
    // 用来将state数据进行加工
const getters = {

    }
    // 新建并暴露store
export default new Vuex.Store({
    state,
    actions,
    mutations,
    getters,
    modules: {
        print
    },
})